home *** CD-ROM | disk | FTP | other *** search
/ PC/CD Gamer UK 120 / CD Gamer Issue 120 (March 2003) (Disc 2).ISO / mods / Q2_Codered / codeRED1_0.exe / Data1.cab / M_bigray.c < prev    next >
Encoding:
C/C++ Source or Header  |  2002-12-30  |  7.9 KB  |  322 lines

  1. /*
  2. ==============================================================================
  3.  
  4. bigray Ray Gun
  5.  
  6. ==============================================================================
  7. */
  8.  
  9. #include "g_local.h"
  10. #include "m_bigray.h"
  11.  
  12.  
  13. static int sound_pain;
  14. static int sound_die;
  15. static int sound_idle;
  16. static int sound_punch;
  17. static int sound_sight;
  18. static int sound_search;
  19.  
  20.  
  21.  
  22. void bigray_search (edict_t *self)
  23. {
  24.     gi.sound (self, CHAN_VOICE, sound_search, 1, ATTN_NORM, 0);
  25. }
  26.  
  27.  
  28. void bigray_fidget (edict_t *self);
  29. mframe_t bigray_frames_stand [] =
  30. {
  31.     ai_stand, 0, bigray_fidget,
  32.     ai_stand, 0, NULL,
  33.     ai_stand, 0, NULL,
  34.     ai_stand, 0, NULL,
  35.     ai_stand, 0, NULL,
  36.     ai_stand, 0, NULL,
  37.     ai_stand, 0, NULL
  38.     
  39. };
  40. mmove_t bigray_move_stand = {FRAME_stand01, FRAME_stand06, bigray_frames_stand, NULL};
  41.  
  42. void bigray_stand (edict_t *self)
  43. {
  44.     self->monsterinfo.currentmove = &bigray_move_stand;
  45. }
  46.  
  47. mframe_t bigray_frames_stand_fidget [] =
  48. {
  49.     ai_stand, 0, NULL,
  50.     ai_stand, 0, NULL,
  51.     ai_stand, 0, NULL,
  52.     ai_stand, 0, NULL,
  53.     ai_stand, 0, NULL,
  54.     ai_stand, 0, NULL
  55. };
  56. mmove_t bigray_move_stand_fidget = {FRAME_stand01, FRAME_stand06, bigray_frames_stand_fidget, bigray_stand};
  57.  
  58. void bigray_fidget (edict_t *self)
  59. {
  60.     if (self->monsterinfo.aiflags & AI_STAND_GROUND)
  61.         return;
  62.     if (random() > 0.15)
  63.         return;
  64.  
  65.     self->monsterinfo.currentmove = &bigray_move_stand_fidget;
  66.     gi.sound (self, CHAN_WEAPON, sound_idle, 1, ATTN_IDLE, 0);
  67. }
  68.  
  69.  
  70. mframe_t bigray_frames_walk [] =
  71. {
  72.     ai_walk, 0, NULL,
  73.     ai_walk, 0, NULL,
  74.     ai_walk, 0, NULL,
  75.     ai_walk, 0, NULL,
  76.     ai_walk, 0, NULL,
  77.     ai_walk, 0, NULL
  78. };
  79. mmove_t bigray_move_walk = {FRAME_stand01, FRAME_stand06, bigray_frames_walk, NULL};
  80.  
  81. void bigray_walk (edict_t *self)
  82. {
  83.     self->monsterinfo.currentmove = &bigray_move_walk;
  84. }
  85.  
  86.  
  87. mframe_t bigray_frames_run1 [] =
  88. {
  89.     ai_run, 0, NULL,
  90.     ai_run, 0, NULL,
  91.     ai_run, 0, NULL,
  92.     ai_run, 0, NULL,
  93.     ai_run, 0, NULL,
  94.     ai_run, 0, NULL
  95. };
  96. mmove_t bigray_move_run1 = {FRAME_stand01, FRAME_stand06, bigray_frames_run1, NULL};
  97.  
  98. void bigray_run (edict_t *self)
  99. {
  100.     //if (self->monsterinfo.aiflags & AI_STAND_GROUND)
  101.         //self->monsterinfo.currentmove = &bigray_move_stand;
  102. //    else
  103.         self->monsterinfo.currentmove = &bigray_move_run1;
  104. }
  105.  
  106.  
  107. void bigray_attack_spike (edict_t *self)
  108. {
  109.     static    vec3_t    aim = {MELEE_DISTANCE, 0, -24};
  110.     fire_hit (self, aim, (15 + (rand() % 6)), 100);        //    Faster attack -- upwards and backwards
  111. }
  112.  
  113.  
  114. void bigray_swing (edict_t *self)
  115. {
  116.     gi.sound (self, CHAN_WEAPON, sound_punch, 1, ATTN_NORM, 0);
  117. }
  118.  
  119. void bigrayShot (edict_t *self)
  120. {
  121.     vec3_t    forward, right;
  122.     vec3_t    start;
  123.     vec3_t    end;
  124.     vec3_t    dir;
  125.     vec3_t    from;
  126.     int        damage = 50;
  127.     int        flash_number = MZ2_MAKRON_BFG;
  128.     trace_t tr;
  129.  
  130.     AngleVectors (self->s.angles, forward, right, NULL);
  131.     G_ProjectSource (self->s.origin, monster_flash_offset[flash_number], forward, right, start);
  132.     VectorCopy (self->s.origin, start);
  133.     VectorCopy (self->enemy->s.origin, end);
  134.     end[2] += self->enemy->viewheight;
  135.     VectorSubtract (end, start, dir);
  136.     //right[0] = right[0] * 6;
  137.     //right[1] = right[1] * 6;
  138.     //VectorAdd(start, right, start);
  139.     end[2] = end[2] - 32;
  140.     start[2] = start[2] + 46;
  141.     VectorCopy (start, from);
  142.     tr = gi.trace (from, NULL, NULL, end, self, MASK_SHOT);      
  143.     VectorCopy (tr.endpos, from);
  144.  
  145.     gi.WriteByte (svc_temp_entity);
  146.     gi.WriteByte (TE_SHOTGUN);
  147.     gi.WritePosition (start);
  148.     gi.WritePosition (end);
  149.     gi.multicast (start, MULTICAST_PHS); 
  150.     
  151.     gi.sound (self, CHAN_VOICE, sound_punch, 1, ATTN_NORM, 0);
  152.     
  153.     if ((tr.ent != self) && (tr.ent->takedamage))
  154.         T_Damage (tr.ent, self, self, dir, tr.endpos, tr.plane.normal, damage, 0, 0, MOD_HYPERBLASTER);
  155.     else if (!((tr.surface) && (tr.surface->flags & SURF_SKY)))
  156.     {  
  157.         gi.WriteByte (svc_temp_entity);
  158.         gi.WriteByte (TE_SCREEN_SPARKS);
  159.         gi.WritePosition (tr.endpos);
  160.         gi.WriteDir (tr.plane.normal);
  161.         gi.multicast (self->s.origin, MULTICAST_PVS);
  162.     }
  163.  
  164.     gi.WriteByte (svc_temp_entity);
  165.     gi.WriteByte (TE_EXPLOSION1);
  166.     gi.WritePosition (end);
  167.     gi.multicast (end, MULTICAST_PVS);
  168. }    
  169.  
  170.  
  171. void bigray_attack_club (edict_t *self)
  172. {
  173.     vec3_t    aim;
  174.  
  175.     VectorSet (aim, MELEE_DISTANCE, self->mins[0], -4);
  176.     fire_hit (self, aim, (5 + (rand() % 6)), 400);        // Slower attack
  177. }
  178.  
  179. mframe_t bigray_frames_attack_shoot [] =
  180. {    
  181.     ai_charge, 0, NULL,
  182.     ai_charge, 0, NULL,
  183.     ai_charge, 0, NULL,
  184.     ai_charge, 0, NULL,
  185.     ai_charge, 0, bigrayShot,
  186.     ai_charge, 0, NULL,
  187.     ai_charge, 0, NULL
  188. };
  189. mmove_t bigray_move_attack_shoot = {FRAME_stand01, FRAME_stand06, bigray_frames_attack_shoot, bigray_run};
  190.  
  191.  
  192. void bigray_sight (edict_t *self, edict_t *other)
  193. {
  194.     gi.sound (self, CHAN_VOICE, sound_sight, 1, ATTN_NORM, 0);
  195.     
  196. }
  197.  
  198. void bigray_attack (edict_t *self)
  199. {
  200.     self->monsterinfo.currentmove = &bigray_move_attack_shoot;
  201. }
  202.  
  203. mframe_t bigray_frames_pain1 [] =
  204. {
  205.     ai_move, 0, NULL,
  206.     ai_move, 0, NULL,
  207.     ai_move, 0, NULL,
  208.     ai_move, 0, NULL,
  209.     ai_move, 0, NULL,
  210.     ai_move, 0, NULL
  211. };
  212. mmove_t bigray_move_pain1 = {FRAME_stand01, FRAME_stand06, bigray_frames_pain1, bigray_run};
  213.  
  214. void bigray_pain (edict_t *self, edict_t *other, float kick, int damage)
  215. {
  216.     if (self->health < (self->max_health / 2))
  217.         self->s.skinnum = 1;
  218.  
  219.     if (level.time < self->pain_debounce_time)
  220.         return;
  221.  
  222.     self->pain_debounce_time = level.time + 3;
  223.     gi.sound (self, CHAN_VOICE, sound_pain, 1, ATTN_NORM, 0);
  224.     self->monsterinfo.currentmove = &bigray_move_pain1;
  225. }
  226.  
  227.  
  228. void bigray_dead (edict_t *self)
  229. {
  230.     VectorSet (self->mins, -16, -16, -42);
  231.     VectorSet (self->maxs, 16, 16, -8);
  232.     self->movetype = MOVETYPE_TOSS;
  233.     self->svflags |= SVF_DEADMONSTER;
  234.     self->nextthink = 0;
  235.     gi.linkentity (self);
  236.  
  237. }
  238.  
  239.  
  240. mframe_t bigray_frames_death1 [] =
  241. {
  242.     ai_move, 0, NULL,
  243.     ai_move, 0, NULL,
  244.     ai_move, 0, NULL,
  245.     ai_move, 0, NULL,
  246.     ai_move, 0, NULL
  247.     
  248.     
  249. };
  250. mmove_t bigray_move_death1 = {FRAME_stand01, FRAME_stand05, bigray_frames_death1, bigray_dead};
  251.  
  252. void bigray_die (edict_t *self, edict_t *inflictor, edict_t *attacker, int damage, vec3_t point)
  253. {
  254.     int n;
  255.  
  256.     gi.sound (self, CHAN_VOICE, sound_die, 1, ATTN_NORM, 0);
  257.  
  258.     gi.WriteByte (svc_temp_entity);
  259.     gi.WriteByte (TE_EXPLOSION1);
  260.     gi.WritePosition (self->s.origin);
  261.     gi.multicast (self->s.origin, MULTICAST_PVS);
  262.  
  263.     for (n = 0; n < 8; n++)
  264.         ThrowGib (self, "models/objects/gibs/mart_gut/tris.md2", damage, GIB_ORGANIC, EF_GREENGIB);
  265.     
  266.     ThrowHead (self, "models/objects/gibs/mart_head/tris.md2", damage, GIB_ORGANIC, EF_GREENGIB);
  267.     
  268.     self->deadflag = DEAD_DEAD;
  269. }
  270.  
  271.  
  272. /*QUAKED monster_bigray (1 .5 0) (-16 -16 -24) (16 16 32) Ambush Trigger_Spawn Sight
  273. */
  274. void SP_monster_bigray (edict_t *self)
  275. {
  276.     if (deathmatch->value)
  277.     {
  278.         G_FreeEdict (self);
  279.         return;
  280.     }
  281.  
  282.     // pre-caches
  283.     sound_pain  = gi.soundindex ("bigray/fizz.wav");
  284.     sound_die   = gi.soundindex ("bigray/fizz.wav");
  285.     sound_idle  = gi.soundindex ("bigray/weird2.wav");
  286.     sound_punch = gi.soundindex ("bigray/shoot.wav");
  287.     sound_search = gi.soundindex ("bigray/weird2.wav");
  288.     sound_sight = gi.soundindex ("bigray/weird2.wav");
  289.  
  290.     self->s.modelindex = gi.modelindex("models/monsters/martian_raygun/tris.md2");
  291.     self->s.modelindex2 = gi.modelindex("models/monsters/hi_res/martian_bigray/tris.md2");
  292.  
  293.     VectorSet (self->mins, -16, -16, -8);
  294.     VectorSet (self->maxs, 16, 16, 48);
  295.     self->movetype = MOVETYPE_STEP;
  296.     self->solid = SOLID_BBOX;
  297.  
  298.     self->max_health = 250;
  299.     self->health = self->max_health;
  300.     self->gib_health = 0;
  301.     self->mass = 250;
  302.  
  303.     self->pain = bigray_pain;
  304.     self->die = bigray_die;
  305.  
  306.     self->monsterinfo.stand = bigray_stand;
  307.     self->monsterinfo.walk = bigray_walk;
  308.     self->monsterinfo.run = bigray_run;
  309.     self->monsterinfo.dodge = NULL;
  310.     self->monsterinfo.attack = bigray_attack;
  311.     self->monsterinfo.melee = bigray_attack;
  312.     self->monsterinfo.sight = bigray_sight;
  313.     self->monsterinfo.search = bigray_search;
  314.  
  315.     self->monsterinfo.currentmove = &bigray_move_stand;
  316.     self->monsterinfo.scale = MODEL_SCALE;
  317.  
  318.     gi.linkentity (self);
  319.  
  320.     walkmonster_start (self);
  321. }
  322.